<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 李文文
  Date: 2020/10/6
  Time: 17:53
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false"%>
<html>
<head>
    <!-- 指定字符集 -->
    <meta charset="utf-8">
    <!-- 使用Edge最新的浏览器的渲染方式 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- viewport视口：网页可以根据设置的宽度自动进行适配，在浏览器的内部虚拟一个容器，容器的宽度与设备的宽度相同。
    width: 默认宽度与设备的宽度相同
    initial-scale: 初始的缩放比，为1:1 -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>添加用户</title>

    <!-- 1. 导入CSS的全局样式 -->
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <!-- 2. jQuery导入，建议使用1.9以上的版本 -->
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <!-- 3. 导入bootstrap的js文件 -->
    <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <style>
        tr:nth-child(odd) {
            background-color: #fcf8e3;
        }
        .modal-backdrop {
            filter: alpha(opacity=0)!important;
            opacity: 0!important;
        }
    </style>

</head>

<body>


<div  style="margin-right: 160px;">
    <div class="container">
        <ul class="breadcrumb" style="  background-color: rgb(255, 255, 255);">
            <li>
                <a href="/firstPage">主页</a>
                <span class="divider"> »</span>
            </li>
            <li class="active">
                流动人口登记信息
                <span class="divider"> »</span>
            </li>
        </ul>
        <table id="tab" class="table table-bordered table-hover"
               style="overflow:hidden;border: 2px #000;border-radius: 3px;width:1200px;margin-left: 42px">
            <thead>
            <tr class="info">
                <td>姓名</td>
                <td>性别</td>
                <td>民族</td>
                <td>身份证号</td>
                <td>户籍所在地</td>
                <td>现居住地</td>
                <td>流入时间</td>
                <td>操作</td>
            </tr>
            </thead>

            <c:forEach items="${undocumentedWorkersList}" var="undocumentedWorkers">
                <tr>
                    <td>${undocumentedWorkers.name}</td>
                    <td>${undocumentedWorkers.sex}</td>
                    <td>${undocumentedWorkers.national}</td>
                    <td>${undocumentedWorkers.ID_number}</td>
                    <td>${undocumentedWorkers.domicile_place}</td>
                    <td>${undocumentedWorkers.address}</td>
                    <td>${undocumentedWorkers.into_time}</td>
                    <td>
                        <button id="update" class="btn btn-warning" style="margin-right: 10px">修改
                        </button>
                        <button id="delete" class="btn btn-danger">删除</button>
                    </td>
                </tr>
            </c:forEach>
        </table>
    </div>
    <button class="btn btn-info" type="button" style="margin-left: 1228px" onclick="open_win()">添加登记信息</button>
</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <form action="${pageContext.request.contextPath}/undocumentedWorkers/updateU" method="post">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title" id="myModalLabel">添加登记信息</h4>
                </div>
                <div class="modal-body">
                    <div class="form-group">
                        <label for="name">姓名：</label>
                        <input type="text" class="form-control" id="name" name="name"></br>
                    </div>
                    <div class="form-group">
                        <label for="sex">性别：</label>
                        <input type="text" class="form-control" name="sex" id="sex"></br>
                    </div>
                    <div class="form-group">
                        <label for="national">民族：</label>
                        <input type="text" class="form-control" name="national"
                               id="national"></br>
                    </div>
                    <div class="form-group">
                        <label for="ID_number">身份证号：</label>
                        <input type="text" class="form-control" id="ID_number"
                               name="ID_number"></br>
                    </div>
                    <div class="form-group">
                        <label for="domicile_place">户籍所在地：</label>
                        <input type="text" class="form-control" id="domicile_place"
                               name="domicile_place"></br>
                    </div>
                    <div class="form-group">
                        <label for="address">现居住地：</label>
                        <input type="text" class="form-control" id="address"
                               name="address"></br>
                    </div>
                    <div class="form-group">
                        <label for="into_time">流入时间：</label>
                        <input type="text" class="form-control" id="into_time"
                               name="into_time"></br>
                    </div>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal"><span
                            class="glyphicon glyphicon-remove" aria-hidden="true"></span>关闭</button>
                    <input type="submit" class="btn btn-primary"  value="保存"  >
                </div>

            </div>
        </form>
    </div>
</div>
<div class="modal fade" id="deleteChild" tabindex="-1" role="dialog" >
    <div class="modal-dialog" role="document">
        <form action="${pageContext.request.contextPath}/undocumentedWorkers/deleteU" method="post">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" >删除子女信息</h4>
                </div>
                <div class="modal-body">
                    <h3>
                        是否删除<input type="text"  id="deleteName" style= "background-color:transparent;border:0;" disabled  />
                        <input type="text"  id="ID" name="ID"  readonly style="display:none;" />
                    </h3>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>关闭</button>
                    <input type="submit" class="btn btn-danger" value="删除"  >
                </div>
            </div>
        </form>
    </div>
</div>



</body>
</html>
<script>
    $(function() {
        $("#tab").on("click", "#update", function(event) {
            $('#myModal').modal();
            $("#name").val($(this).closest("tr").find("td").eq(0).text());
            $("#sex").val($(this).closest("tr").find("td").eq(1).text());
            $("#national").val($(this).closest("tr").find("td").eq(2).text());
            $("#ID_number").val($(this).closest("tr").find("td").eq(3).text());
            $("#domicile_place").val($(this).closest("tr").find("td").eq(4).text());
            $("#address").val($(this).closest("tr").find("td").eq(5).text());
            $("#into_time").val($(this).closest("tr").find("td").eq(6).text());
        });
        $("#tab").on("click", "#delete", function(event) {
            $('#deleteChild').modal();
            $("#deleteName").val($(this).closest("tr").find("td").eq(0).text());
            $("#ID").val($(this).closest("tr").find("td").eq(3).text());
        });
    });
    function open_win() {
        window.open("${pageContext.request.contextPath}/undocumentedWorkers/addUPage");
    }
</script>
